(* camera.ml
 *
 * This file is part of camEngine
 * 
 * camEngine - A 3d motor for ocaml
 * Copyright (C) 2009 DAVY Guillaume <davyg2@gmail.com>
 *
 * camEngine is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * camEngine is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with camEngine.  If not, see <http://www.gnu.org/licenses/>.
 *)

open Vec3d;;
open Mesh;;
open Array;;
open Driver;;
open Node;;
open Matrice;;

class camera = object (this)

	inherit node as myNode
	val mutable projection = new matrice4
	val mutable view = new matrice4
	val mutable far = 0.
	val mutable near = 0.
	
	method set_pos p =
		myNode#set_pos p;
		(* Change the good matrice to take care of the coordinate*)
	
	(*method set_rot r =
		myNode#set_rot r;
	
	method set_sca s =
		myNode#set_sca s;*)
	
	method set_far f =
		far <- f;
	
	method set_near n =
		near <- n;
	
	method get_far = far;
	
	method get_near = near;
		
	method render (d:driver) =
		myNode#render d;
		view <- Oo.copy transform;
		view#reverse;
		d#set_projection projection;
		d#set_view view;
		d#set_far far;
	
	initializer
	();
end;;


